package com.iwat.hellospringcache.demos.web.service.impl;

import com.iwat.hellospringcache.demos.web.User;
import com.iwat.hellospringcache.demos.web.service.*;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author 王伟强
 * @date 2024/1/13 9:58
 */
@Service
public class UserServiceImpl implements UserService {
    private static  final String REDIS_KEY = "test:cache";
    @Cacheable(value = REDIS_KEY,key = "#root.methodName+'_'+#id")
    @Override
    public User getUserById(Integer id) {
        User user = new User();
        user.setName("吴伟");
        user.setAge(24);
        return user;
    }
}
